/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package AccountDTO;

import java.util.*;
/**
 *
 * @author Phuong Giang
 */
public class AccountCollection {
    protected List<AccountExtended> accounts;

    public AccountCollection() {
        this.accounts = new ArrayList<AccountExtended>();
    }

    public AccountCollection(List<AccountExtended> onlineAccount) {
        this.accounts = onlineAccount;
    }

    public List<AccountExtended> getAccounts() {
        return accounts;
    }

    public void setOnlineAccount(List<AccountExtended> onlineAccount) {
        this.accounts = onlineAccount;
    }

    public AccountExtended getAccount(String username) {
        for(AccountExtended acc : accounts) {
            if(acc.getUsername().equals(username)) {
                return acc;
            }
        }
        return null;
    }

    public void add(Account acc) {
        add(new AccountExtended(acc));
    }

    public void add(AccountExtended acc) {
        accounts.add(acc);
    }

    public void remove(AccountExtended acc) {
        accounts.remove(acc);
    }

    public void remove(String username) {
        accounts.remove(getAccount(username));
    }

    public int size() {
        return accounts.size();
    }

}
